package com.forecasting.testclass;

import java.io.*;
import java.util.*;

import com.forecasting.interfaces.Distribution;
import com.forecasting.model.*;
import com.forecasting.statistic.NormalDistribution;
import com.forecasting.statistic.PoissonDistribution;

public class testRandom {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		PartNumber pn1 = new PartNumber("333-444-0","Washer 5inch","sdssdsdsdsdsdsdsdsd",1,1,2);
		PartNumber pn2 = new PartNumber("666-444-0","Washer 6inch","gggggggggggggg",2,2,3);
		PartNumber pn3 = new PartNumber("777-444-0","Washer 7 inch","sdssdsdsdsdsdsdsdsd",4,1,5);
		PartNumber pn4 = new PartNumber("3888-555-6007","Ring Washer 10 inch","sdssdsdsdsdsdsdsdsd",2,1,4);
		
		PoissonDistribution ps1 = new PoissonDistribution(pn1);
		PoissonDistribution ps2 = new PoissonDistribution(pn2);
		PoissonDistribution ps3 = new PoissonDistribution(pn3);
		PoissonDistribution ps4 = new PoissonDistribution(pn4);
		NormalDistribution ns1 = new NormalDistribution(pn4);
		
		ArrayList<PartNumber> pnlist = new ArrayList<PartNumber>();
		
		pnlist.add(pn1);
		pnlist.add(pn2);
		pnlist.add(pn3);
		pnlist.add(pn4);
		
		ArrayList<Distribution> distlist = new ArrayList<Distribution>();
		distlist.add(ps1);
		distlist.add(ps2);
		distlist.add(ps3);
		distlist.add(ps4);
		distlist.add(ns1);
		
		try {
			ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("partnumber.txt"));
			out.writeObject(pnlist);
			out.close();
			
			ObjectInputStream in = new ObjectInputStream(new FileInputStream("partnumber.txt"));
			ArrayList<PartNumber> newpnlist = (ArrayList<PartNumber>) in.readObject();
			in.close();
			
			for(PartNumber p : newpnlist){
				System.out.println(p.toString());
			}
			
//			ObjectOutputStream out1 = new ObjectOutputStream(new FileOutputStream("distribution.txt"));
//			out1.writeObject(distlist);
//			out1.close();
//			
//			ObjectInputStream in1 = new ObjectInputStream(new FileInputStream("distribution.txt"));
//			ArrayList<Distribution> newdistlist = (ArrayList<Distribution>) in1.readObject();
//			in1.close();
//			
//			for(Distribution p : newdistlist){
//				System.out.println(p.toString());
//			}
			
			
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
